<?php
namespace Home\Controller;
use Think\Controller;
class BaseController extends Controller {
	public function _initialize() {
		if ($_SESSION) {
			$Auth = new \Think\Auth();
			//需要验证的规则列表,支持逗号分隔的权限规则或索引数组
			$name = MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME;
			// 		var_dump($name);
			//当前用户id
			$uid = $_SESSION["id"];
			//session的值
			if (!$Auth -> check($name, $uid)) {
				$this->assign('errorMessage','无权访问');
				$this->assign('errorCode','403');
				$this->assign('waitSecond','5');
				$this->assign('errorMessage2','当前账户无权访问该内容');
				$this->assign('jumpUrl','/home/user/info');
				$this->error();
			}
		} else {
			$this->assign('errorMessage','无权访问');
			$this->assign('errorCode','403');
			$this->assign('waitSecond','5');
			$this->assign('errorMessage2','请先登录');
			$this->assign('jumpUrl','/');
			$this->error();
//			header("Location:http:/home/index/index");
		}

	}

}
?>